//
//  UIImage+iOS6and7.m
//  01-weibo
//
//  Created by 王戈 on 14-7-3.
//  Copyright (c) 2014年 itcast. All rights reserved.
//

#import "UIImage+iOS6and7.h"

@implementation UIImage (iOS6and7)
+ (UIImage *)imageWithName:(NSString *)name
{
    UIImage *image = nil;
    if (YES) {
        NSString *newName = [name stringByAppendingString:@"_os7"];
        image = [UIImage imageNamed:newName];
    }
    if (image == nil) {
        image = [UIImage imageNamed:name];
    }
    return image;
}

+ (UIImage *)resizeImage:(NSString *)imageName
{
    UIImage *image = [UIImage imageWithName:imageName];
    
    return [image stretchableImageWithLeftCapWidth:image.size.width * 0.5 topCapHeight:image.size.height * 0.5];
}

- (CGSize)suitableSize
{
    CGFloat width = self.size.width;
    CGFloat height = self.size.height;
    CGFloat whRate = width/height;
    
    if (whRate > SCREEN_WIDTH/SCREEN_HEIGHT) {
        // 如果是宽太长 ,就拿长作为基准
        return CGSizeMake(SCREEN_WIDTH *0.8, SCREEN_WIDTH * height / width*0.8);
    } else {
        // 如果是高太长 ,就拿高作基准
        return CGSizeMake(SCREEN_HEIGHT * width / height*0.8, SCREEN_HEIGHT*0.8);
    }
}
@end
